window.onload = function(){
	var item = document.getElementsByClassName("item");
	var it = item[0].getElementsByTagName("div");
	
	var content = document.getElementsByClassName("content");
	var con = content[0].getElementsByTagName("div");
	
	for(let i=0;i<it.length;i++){
		it[i].onclick = function(){
			for(let j=0;j<it.length;j++){
				it[j].className = '';
				con[j].style.display = "none";
			}
			this.className = "active";
			it[i].index=i;
			con[i].style.display = "block";
		}
	}
}
function login() {
	console.log("1111")
	var loginEmail = document.getElementById("loginEmail");
	var loginPassword = document.getElementById("loginPassword");
	var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
	if(loginEmail.value ==""){
		alert("邮箱不能为空！")
		loginEmail.focus()
		return false;
	}else if(!pattern.test(loginEmail.value)){
		alert("邮箱格式错误！应该为xxx@xx这样")
		loginEmail.focus()
		return false;
	}
	if(loginPassword.value == ""){
		alert("密码不能为空！")
		loginPassword.focus()
		return false;
	}else if(loginPassword.value.length <6){
		alert("密码不能少于6位！")
		loginPassword.focus()
		return false;
	}
	return true;
}
function reigister() {
	var reigisterEmail = document.getElementById("reigisterEmail");
	var reigisterPassword = document.getElementById("reigisterPassword");
	var reigisterUsername = document.getElementById("reigisterUsername");
	var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
	if(reigisterEmail.value ==""){
		alert("邮箱不能为空！")
		loginEmail.focus()
		return false;
	}else if(!pattern.test(reigisterEmail.value)){
		alert("邮箱格式错误！应该为xxx@xx这样")
		reigisterEmail.focus()
		return false;
	}
	if(reigisterPassword.value == ""){
		alert("密码不能为空！")
		loginPassword.focus()
		return false;
	}else if(reigisterPassword.value.length <6){
		alert("密码不能少于6位！")
		loginPassword.focus()
		return false;
	}
	if(reigisterUsername.value == ""){
		alert("用户名不能为空！")
		loginPassword.focus()
		return false;
	}
	return true;
}